import { IPages, IResponse, IPagesParams } from './index.type'
import { IGoods, ISameLevelCategory } from './category.type'
import { IBrand } from './home.type'

// findTemporary api type
export interface IAttr {
  groupName: string
  propertyName: string
}

export type ISortField =
  | 'publishTime'
  | 'orderNum'
  | 'evaluateNum'
  | 'price'
  | null

export type ISortMethod = 'desc' | 'asc' | null

export interface ITemporaryParams extends IPagesParams {
  categoryId: string | null
  brandId?: string | null
  attrs?: IAttr[] | null
  inventory?: boolean
  onlyDiscount?: boolean
  sortField?: ISortField
  sortMethod?: ISortMethod
}

export interface ITemporary extends IPages {
  conuts: number
  items: IGoods[]
}

export type ITemoraryResponse = IResponse<ITemporary>

//findGoodsDetail api type

export interface IGoodsProperty {
  name: string
  value: string
}
export interface IDetails {
  pictures: string[]
  properties: IGoodsProperty[]
}

export interface ISpecsValues {
  desc: string
  name: string
  picture: null | string
  disabled?: boolean
  selected?: boolean
}
export interface ISpecs {
  name: string
  values: ISpecsValues[]
}

export interface ISkuSpecs {
  name: string
  valueName: string
}
export interface ISkus {
  id: string
  inventory: number
  oldPrice: string
  price: string
  skuCode: string
  specs: ISkuSpecs[]
}

export interface IGoodsDetail {
  brand: IBrand
  categories: ISameLevelCategory[]
  collectCount: number
  commentCount: number
  desc: string
  details: IDetails
  discount: 1
  evaluationInfo: null | string
  hotByDay: IGoods[]
  mainPictures: string[]
  mainVideos: string[]
  id: string
  name: string
  oldPrice: string
  price: string
  recommends: string
  salesCount: number
  similarProducts: IGoods[]
  specs: ISpecs[]
  skus: ISkus[]
  spuCode: string
  userAddresses: string
  videoScale: string
}

export type IGoodsDetailResonse = IResponse<IGoodsDetail>

export type IGoodsRelevantResponse = IResponse<IGoods[]>

// findHotGoods api type
export enum HotType {
  dayHotRank,
  weekHotRank,
  totalHotRank
}

export type IHotGoodsResponse = IResponse<IGoods[]>

// findCommentInfoByGoods api type

export interface IEvaluate {
  salesCount: number
  praisePercent: string
  evaluateCount: number
  hasPictureCount: number
  tags: ITag[]
}
export interface ITag {
  title: string
  tagCount: number
}

export type IEvaluateResponse = IResponse<IEvaluate>

// findGoodsCommentListById api type
export interface goodsCommentsListParams extends IPagesParams {
  sortField?: '' | 'praiseCount' | 'createTime'
  tag?: string
  hasPicture?: boolean
}

export interface OrderInfoSpec {
  name: string
  nameValue: string
}
export interface OrderInfo {
  specs: OrderInfoSpec[]
  quantity: number
  createTime: string
}

export interface Member {
  id: string
  nickname: string
  avatar: string
}

export interface IGoodComment {
  id: number
  orderInfo: OrderInfo
  member: Member
  score: number
  tags: string[]
  content: string
  pictures: string[]
  officialReply: string
  praiseCount: number
  createTime: string
}

export interface IGoodsCommentInfo extends IPages {
  counts: number
  items: IGoodComment[]
}

export type IGoodCommentInfoResponse = IResponse<IGoodsCommentInfo>
